/**
 *
 */
package co.fitstart.api.web.controller.content;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo2do.core.support.Page;
import com.demo2do.core.support.Result;
import com.demo2do.core.utils.JsonUtils;

import co.fitstart.api.service.ContentService;
import co.fitstart.entity.content.News;

/**
 * @author downpour
 *
 */
@Controller
@RequestMapping("/v1/news")
public class NewsApiController {

    @Autowired
    private ContentService contentService;

    /**
     * List news
     *
     * @param page
     * @return
     */
    @RequestMapping("")
    public @ResponseBody String list(Page page) {
        Result result = new Result();
        List<News> news = contentService.listNews(page);
        result.success().data("page", page)
                        .data("news", news);
        return JsonUtils.toJsonString(result);
    }

}
